exports.controllers={
	admin_generic_controller: function(space,modelname) {
		if (!modelname) throw("needs a model name!");
		var mode=space.fields.mode||"list";
		switch (mode) {
			case "list":
				space.arows=space.mfact.list(modelname,{});
				return space.views.process("_auto/"+modelname+"/admin_"+mode,space);
				break;
			case "edit":
				space.item={};
				if (space.fields.id) space.item=space.mfact.get(modelname,space.fields.id);
				return space.views.process("_auto/"+modelname+"/admin_"+mode,space);
				break;
			case "save":
				var item=space.mfact.from_object(modelname,space.fields);
				item.Save();
				return JSON.stringify({redirect:{url: space.action}});
				break;
			case "delete":
				space.alist=space.mfact.get(space.models[modelname],{pk: space.fields.id});
				return space.views.process("_auto/"+modelname+"/admin_"+mode,space);
				break;
			case "delete_save":
				break;
		} 
	}
};
